import { defineStore } from 'pinia'
// import { getApiList } from '../server'
import axios from 'axios';
import type { Children, RootObject,ChinaAdd,ChinaTotal,StatisGradeCityDetail } from './type';
export const useStore = defineStore({
  id: 'counter',
  state: () => ({
    //存储json返回数据
    list: <RootObject>{},
    //存储各省信息
    item: <Children[]>[],
    //存储病例数据
    chinaAdd:<ChinaAdd>{},
    chinaTotal:<ChinaTotal>{},
    cityDetail:<StatisGradeCityDetail[]>[],
  }),
  actions: {
    async getData(){
      await axios.get('static/data/data.json')
        .then(res => {
         this.list = res.data
         this.chinaAdd = this.list.diseaseh5Shelf.chinaAdd
         this.chinaTotal = this.list.diseaseh5Shelf.chinaTotal
         this.cityDetail = this.list.statisGradeCityDetail.slice(0,10)
        }).catch(err => {
          console.log(err);
        })
    }
  }
})
